package models.mappers;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import vos.DeviceSearchVo;
import vos.DeviceVo;
import models.Device;
import models.DeviceStatus;
import models.Standard;

public interface DeviceMapper {
	/**
	 * 统计列表行数
	 *
	 * @Title: countHraDetail 
	 * @param vo
	 * @return
	 * @return: long
	 */
	long countDevice(DeviceSearchVo vo);
	/**
	 * 获取列表数据
	 *
	 * @Title: listHraStandard 
	 * @param vo
	 * @return
	 * @return: List<Standard>
	 */
	List<DeviceVo> listDevice(DeviceSearchVo vo);
	/**
	 * 批量启用门店
	 *
	 * @Title: betchEnable 
	 * @param listid 门店id列表
	 * @return
	 * @return: Boolean
	 */
	void betchEnable(Map<String, Object> map);
	/**
	 * 批量停用门店
	 *
	 * @Title: betchEnable 
	 * @param listid 门店id列表
	 * @return
	 * @return: Boolean
	 */
	void betchDisable(Map<String, Object> map);
	/**
	 * 批量删除门店
	 *
	 * @Title: betchDel 
	 * @param map
	 * @return: void
	 */
	void betchDel(Map<String, List<String>> map);
	/**
	 * 根据id删除门店
	 *
	 * @Title: delDevice 
	 * @param id
	 * @return: void
	 */
	@Delete("delete from "
			+ Device.TABLE_NAME
			+" where deviceid=#{id}")
	void delDevice(String id);
	/**
	 * 根据id判断是否存在该门店
	 *
	 * @Title: checkCode 
	 * @param deviceid
	 * @return
	 * @return: String
	 */
	@Select("select 1 from "
			+ Device.TABLE_NAME
			+" where deviceid=#{deviceid}")
	String checkCode(String deviceid);
	/**
	 * 根据id获取门店信息
	 *
	 * @Title: getById 
	 * @param deviceid 门店id
	 * @return
	 * @return: Device
	 */
	@Select("select * from "
			+ Device.TABLE_NAME
			+" where deviceid=#{deviceid}")
	Device getById(String deviceid);
	/**
	 * 保存门店信息
	 *
	 * @Title: saveDevice 
	 * @param device
	 * @return: void
	 */
	@Insert("insert into "
			+ Device.TABLE_NAME
			+" (deviceid,devicename,shopid,devicemodel,deviceprice,remark,isflag,createtime,createname,status,buildtime) values"
			+ "(#{deviceid},#{devicename},#{shopid},#{devicemodel},#{deviceprice},#{remark},#{isflag},#{createtime},#{createname},'01',#{buildtime})")
	void saveDevice(Device device);
	/**
	 * 更新门店信息
	 *
	 * @Title: updateDevice 
	 * @param device
	 * @return: void
	 */
	@Update("update "
			+ Device.TABLE_NAME
			+" set devicename=#{devicename},"
			+ "shopid=#{shopid},devicemodel=#{devicemodel},"
			+ "deviceprice=#{deviceprice},remark=#{remark},"
			+ "isflag=#{isflag},modifyname=#{modifyname},modifytime=#{modifytime},"
			+ "buildtime=#{buildtime}"
			+ "where deviceid=#{deviceid}")
	void updateDevice(Device device);
	/**
	 * 根据经销商id集合查询设备集合
	 *
	 * @Title: selectByDealers 
	 * @param listid
	 * @return
	 * @return: List<Shop>
	 */
	List<String> selectByDealers(Map<String, List<String>> map);
	/**
	 * 根据门店id集合查询设备集合
	 *
	 * @Title: selectByDealers 
	 * @param listid
	 * @return
	 * @return: List<Shop>
	 */
	List<String> selectByShops(Map<String, List<String>> map);
	/**
	 * 根据门店id获取设备集合
	 *
	 * @Title: findByShop 
	 * @param id
	 * @return
	 * @return: List<Device>
	 */
	@Select("select * from "
			+ Device.TABLE_NAME
			+" where shopid=#{id}")
	List<Device> findByShop(String id);
	/**
	 * 根据门店id停用设备
	 *
	 * @Title: DisableByShops 
	 * @param map
	 * @return: void
	 */
	void DisableByShops(Map<String, Object> map);
	@Select("select * from device_view"
			+ " where deviceid=#{id}")
	DeviceVo getViewById(String id);
	/**
	 * 查询设备状态
	 *
	 * @Title: getStatus 
	 * @return
	 * @return: List<DeviceStatus>
	 */
	@Select("select statusid,statusname from device_status")
	List<DeviceStatus> getStatus();
	/**
	 * 更新设备健康状况
	 *
	 * @Title: updateDeviceStatus 
	 * @param map
	 * @return: void
	 */
	void updateDeviceStatusOk(Map<String, List<String>> map);
	void updateDeviceStatusNotOk(Map<String, List<String>> hraids);
	/**
	 * 根据门店统计设备
	 *
	 * @Title: countDeviceByShop 
	 * @param vo
	 * @return
	 * @return: long
	 */
	long countDeviceByShop(DeviceSearchVo vo);
	/**
	 * 根据门店获取设备列表
	 *
	 * @Title: getDeviceByShop 
	 * @param vo
	 * @return
	 * @return: List<Device>
	 */
	List<DeviceVo> getDeviceByShop(DeviceSearchVo vo);
	/**
	 * 导出为excel
	 *
	 * @Title: exportXls 
	 * @param vo
	 * @return
	 * @return: List<DeviceVo>
	 */
	List<DeviceVo> exportXls(DeviceSearchVo vo);
	/**
	 * 获取下拉框
	 *
	 * @Title: getCombobox 
	 * @return
	 * @return: List<Device>
	 */
	@Select("select * from "
			+ Device.TABLE_NAME)
	List<Device> getCombobox();
	/**
	 * 获取未在id集合中的id
	 *
	 * @Title: getNotIn 
	 * @param map
	 * @return
	 * @return: List<String>
	 */
	List<DeviceVo> getNotIn(Map<String, Object> map);
}
